

cd "/Users/rblakemcmahon/Dropbox/Geopolitical_Competition/data"
*use "econ_militarydata_10-2-2015.dta"
use Make_or_Take_3Oct2017.dta


gen net_territorial_change_max =  area_gained_max_sum -  area_lost_max_sum
gen territory_gained = 1 if area_gained_max > 0
replace territory_gained = 0 if territory_gained == .
gen tpop_100k = tpop*100
gen milper_100k = milper/tpop_100k

gen milper_pc = milper/tpop
gen milper_pcLN = log(milper_pc)
    


xtset ccode year

gen totton_pc = totton/tpop
gen pec_pc = pec/tpop
gen gdp_pc = gdp/tpop
gen milperLN = ln(milper+1)
gen gdpLN = log(gdp+1)
gen gdp_pc_ln = log(gdp_pc+1)
gen pec_pc_ln = log(pec_pc+1)
gen totton_pc_ln = log(totton_pc+1)



******TABLE 2--TERRITORIAL MIDS********

eststo clear

eststo: logit  territory_binary pec_pc_ln  gdp_pc_ln threat territory_binary_years territory_binary_years_squared territory_binary_years_cubed, cluster(ccode)
eststo: logit  territory_binary pec_pc_ln  gdp_pc_ln threat polity2 territory_binary_years territory_binary_years_squared territory_binary_years_cubed, cluster(ccode)
eststo: logit  territory_binary  pec_pc_ln gdp_pc_ln threat polity2 land sea  territory_binary_years territory_binary_years_squared territory_binary_years_cubed, cluster(ccode)
eststo: logit  territory_binary  pec_pc_ln threat polity2 land sea  territory_binary_years territory_binary_years_squared territory_binary_years_cubed, cluster(ccode)


*esttab using "logit_territory_10-3-2017_1.tex", replace cells(b(star fmt(4)) se(par fmt(3))) title(TOTTONpc Tests\label{tab1})



****TABLE 3--DISTANCE AWAY*****


gen distance_max_ln = log(distance_max+1)
gen distance_avg_ln = log(distance_avg+1)
replace distance_avg_ln = . if year > 2001  

eststo clear

eststo: xtpcse distance_avg_ln pec_pc_ln gdp_pc_ln threat, correlation(ar1) pairwise
eststo: xtpcse distance_avg_ln pec_pc_ln gdp_pc_ln threat polity2, correlation(ar1) pairwise
eststo: xtpcse distance_avg_ln pec_pc_ln gdp_pc_ln threat polity2 land sea, correlation(ar1) pairwise
eststo: xtpcse distance_avg_ln pec_pc_ln  threat polity2 land sea, correlation(ar1) pairwise

*esttab using "PCSE_distance_main_10-3-2017.tex", replace cells(b(star fmt(4)) se(par fmt(3))) title(TOTTONpc Tests\label{tab1})


****TABLE 4--NAVAL TONNAGE*****

eststo clear

eststo: xtpcse totton_pc_ln pec_pc_ln gdp_pc_ln threat, correlation(ar1) pairwise
eststo: xtpcse totton_pc_ln pec_pc_ln gdp_pc_ln threat polity2, correlation(ar1) pairwise
eststo: xtpcse totton_pc_ln pec_pc_ln gdp_pc_ln threat polity2 land sea, correlation(ar1) pairwise
eststo: xtpcse totton_pc_ln pec_pc_ln  threat polity2 land sea, correlation(ar1) pairwise

*esttab using "navies_output10-3-2017.tex", replace cells(b(star fmt(4)) se(par fmt(3))) title(TOTTONpc Tests\label{tab1})


****TABLE 5--SEE BELOW****


****TABLE 6--Year FE********

eststo clear

eststo: logit  territory_binary pec_pc_ln gdp_pc_ln threat polity2 territory_binary_years territory_binary_years_squared territory_binary_years_cubed i.year
eststo: xtreg distance_avg_ln pec_pc_ln  gdp_pc_ln threat  polity2 i.year
eststo: xtreg totton_pc_ln pec_pc_ln gdp_pc_ln threat polity2 i.year

*esttab using "year_fe_10-2-2017.tex", replace cells(b(star fmt(4)) se(par fmt(3))) title(TOTTONpc Tests\label{tab1})


****TABLE 7--SEE BELOW*****


****Table 8--MID Distance tests only on sample of state years with at least one MID****

eststo clear

gen distance_avg_ln_alt = distance_avg_ln

replace distance_avg_ln_alt = . if distance_avg_ln_alt == 0

eststo: xtpcse distance_avg_ln_alt pec_pc_ln upop tpop milper milex gdp_pc_ln threat, correlation(ar1) pairwise 
eststo: xtpcse distance_avg_ln_alt pec_pc_ln upop tpop milper milex gdp_pc_ln threat polity2, correlation(ar1) pairwise
eststo: xtpcse distance_avg_ln_alt pec_pc_ln upop tpop milper milex gdp_pc_ln threat polity2 land sea, correlation(ar1) pairwise
eststo: xtpcse distance_avg_ln_alt pec_pc_ln upop tpop milper milex threat polity2 land sea, correlation(ar1) pairwise

*esttab using "PCSE_distance_MIDyrsOnly_2017.tex", replace cells(b(star fmt(4)) se(par fmt(3))) title(TOTTONpc Tests\label{tab1})


******TABLE 9--ETHNICALLY SALIENT TERRITORY********

eststo clear

eststo: logit  tcidenchal pec_pc_ln  gdp_pc_ln threat tcidenchalyrs tcidenchalyrs_squared tcidenchalyrs_cubed, cluster(ccode)
eststo: logit  tcidenchal pec_pc_ln  gdp_pc_ln threat polity2 tcidenchalyrs tcidenchalyrs_squared tcidenchalyrs_cubed, cluster(ccode)
eststo: logit  tcidenchal  pec_pc_ln gdp_pc_ln threat polity2 land sea  tcidenchalyrs tcidenchalyrs_squared tcidenchalyrs_cubed, cluster(ccode)

*esttab using "ethnicterritorysalience_10-4-2017_1.tex", replace cells(b(star fmt(4)) se(par fmt(3))) title(TOTTONpc Tests\label{tab1})



******TABLE 10********

eststo clear

eststo: logit  territory_binary pec_pc_ln rent_addiction_high gdp_pc_ln threat polity2 land sea territory_binary_years territory_binary_years_squared territory_binary_years_cubed, cluster(ccode)
eststo: logit  territory_binary pec_pc_ln ag_high_dummy2 gdp_pc_ln threat polity2 land sea territory_binary_years territory_binary_years_squared territory_binary_years_cubed, cluster(ccode)
eststo: logit  territory_binary pec_pc_ln rent_addiction_high ag_high_dummy2 gdp_pc_ln  threat polity2 land sea territory_binary_years territory_binary_years_squared territory_binary_years_cubed, cluster(ccode)
eststo: logit  territory_binary pec_pc_ln oil_gas_gdp gdp_pc_ln threat polity2 land sea  territory_binary_years territory_binary_years_squared territory_binary_years_cubed, cluster(ccode)
eststo: logit  territory_binary  pec_pc_ln ag_gdp_wdi gdp_pc_ln threat polity2 land sea  territory_binary_years territory_binary_years_squared territory_binary_years_cubed, cluster(ccode)

*esttab using "logit_territory_robustcheck_10-3-2017_1.tex", replace cells(b(star fmt(4)) se(par fmt(3))) title(TOTTONpc Tests\label{tab1})



****TABLE 11*****

gen distance_max_ln = log(distance_max+1)
gen distance_avg_ln = log(distance_avg+1)
replace distance_avg_ln = . if year > 2001  

eststo clear


eststo: xtpcse distance_avg_ln pec_pc_ln rent_addiction_high gdp_pc_ln threat polity2 land sea, correlation(ar1) pairwise
eststo: xtpcse distance_avg_ln pec_pc_ln ag_high_dummy2 gdp_pc_ln threat polity2 land sea, correlation(ar1) pairwise
eststo: xtpcse distance_avg_ln pec_pc_ln rent_addiction_high ag_high_dummy2 gdp_pc_ln  threat polity2 land sea, correlation(ar1) pairwise
eststo: xtpcse distance_avg_ln pec_pc_ln oil_gas_gdp gdp_pc_ln threat polity2 land sea, correlation(ar1) pairwise
eststo: xtpcse distance_avg_ln pec_pc_ln ag_gdp_wdi gdp_pc_ln threat polity2 land sea, correlation(ar1) pairwise

*esttab using "PCSE_robust_check_10-3-2017.tex", replace cells(b(star fmt(4)) se(par fmt(3))) title(TOTTONpc Tests\label{tab1})



*****TABLE 12*****

eststo clear

eststo: xtpcse totton_pc_ln pec_pc_ln rent_addiction_high gdp_pc_ln threat polity2 land sea, correlation(ar1) pairwise
eststo: xtpcse totton_pc_ln pec_pc_ln ag_high_dummy2 gdp_pc_ln threat polity2 land sea, correlation(ar1) pairwise
eststo: xtpcse totton_pc_ln pec_pc_ln rent_addiction_high ag_high_dummy2 gdp_pc_ln  threat polity2 land sea, correlation(ar1) pairwise
eststo: xtpcse totton_pc_ln pec_pc_ln oil_gas_gdp gdp_pc_ln threat polity2 land sea, correlation(ar1) pairwise
eststo: xtpcse totton_pc_ln pec_pc_ln  ag_gdp_wdi gdp_pc_ln threat polity2 land sea, correlation(ar1) pairwise

*esttab using "navies_output_robustcheck10-3-2017.tex", replace cells(b(star fmt(4)) se(par fmt(3))) title(TOTTONpc Tests\label{tab1})




*****TABLE 5--POST WWII ERA********
drop if year < 1946

eststo clear
eststo: logit  territory_binary pec_pc_ln gdp_pc_ln threat polity2 territory_binary_years territory_binary_years_squared territory_binary_years_cubed
eststo: xtpcse distance_avg_ln pec_pc_ln  gdp_pc_ln threat polity2,correlation(ar1) pairwise
eststo: xtpcse totton_pc_ln pec_pc_ln gdp_pc_ln threat polity2, correlation(ar1) pairwise
*esttab using "postcolonial_12-8-2015.tex", replace cells(b(star fmt(4)) se(par fmt(3))) title(TOTTONpc Tests\label{tab1})



*****TABLE 7--WITHOUT MAJPOWS--WONKY*********
clear

use Make_or_Take_3Oct2017.dta

xtset ccode year


drop if ccode == 2
drop if ccode == 200
drop if ccode == 220
drop if ccode == 255
drop if ccode == 300
drop if ccode == 325
drop if ccode == 365 
drop if ccode == 710
drop if ccode == 740


eststo clear

eststo: logit  territory_binary pec_pc_ln gdp_pc_ln threat polity2 land sea territory_binary_years territory_binary_years_squared territory_binary_years_cubed
eststo: xtpcse distance_avg_ln pec_pc_ln  gdp_pc_ln threat polity2 land sea,correlation(ar1) pairwise
eststo: xtpcse totton_pc_ln pec_pc_ln gdp_pc_ln threat polity2 land sea, correlation(ar1) pairwise
*esttab using "withoutmajpows_4Oct2017.tex", replace cells(b(star fmt(4)) se(par fmt(3))) title(TOTTONpc Tests\label{tab1})




